28. Exercise: Create and Apply Styles

Create and Apply Styles

Create and apply the following four styles to Sunshine layouts:

  1. An action bar style that shows a Sunshine logo instead of a title; named “ActionBar.Solid.Sunshine.NoTitle”
  2. A style for MainActivity called AppTheme.Forecast that uses the custom ActionBar style
  3. A DetailLabel style that contains all the common style attributes
  4. An ExtraWeatherMeasurement style that contains all the repeated style attributes

Exercise Code

Exercise: S12.02-Exercise-Styles

Create and Apply Styles

Your turn. Check each step when complete.

SOLUTION:
  • Create a style that shows a Sunshine logo instead of a title
  • Create a style for MainActivity called AppTheme.Forecast that uses our custom ActionBar style
  • Create the DetailLabel style
  • Create the ExtraWeatherMeasurement style
  • Use AppTheme.Forecast as the MainActivity's new theme
  • Apply newly created styles to their respective views and layouts